

public class BoardImplFastReverse extends BoardImplFast
{

	public BoardImplFastReverse(CellType[][] board) 
	{
		super(board);
		
		/*
		 * Reverse the board
		 */
		
		Cord[] goalsBackup = goals;
		
		for ( int i = 0; i < goals.length; i++ )
		{
			goals[i] = new CordImpl( boxes[i] );
		}
		
		
	}
	
	public BoardImplFastReverse( final CellType[][] board, final boolean[][] deadlock, byte[] hashArray, short[] boxes, final Cord[] goals, Cord player )
	{
		super( board, deadlock, hashArray, boxes, goals, player, 0 );
	}
	
	
	@Override
	public int doMovePlayer(Move.Direction direction) 
	{
		
		CordImpl PotentialBox = new CordImpl( player.getX()+direction.reverse().getXDiff(), player.getY() + direction.reverse().getYDiff() );
		CordImpl currentCord = (CordImpl) player;
		CordImpl nextCord = new CordImpl( player.getX()+direction.getXDiff(), player.getY() + direction.getYDiff() );
		
		if ( getCellType( nextCord ).isWall() )
		{
			throw new RuntimeException("Bug i Olles kod, nextCord i wall");
		}
		
		if ( getCellType( PotentialBox ).isBox() )
		{
			changeBoxCoordinates( PotentialBox.getCords(), currentCord.getCords() );
		}

		this.player = new CordImpl( nextCord.getX(), nextCord.getY() );
		
		return 1;
	}
	
	
	@Override
	public Board clone()
	{
		
		short[] newBoxes = new short[boxes.length];
		for ( int i = 0; i < boxes.length; i++)
		{
			newBoxes[i] = boxes[i];
		}
		
		return new BoardImplFastReverse( board, deadlock, hashArray ,newBoxes, goals, player.cloneCord() );
		
	}
	
	

}
